package org.base.common.databind;

import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import org.base.common.annotation.JsonEnum;
import org.base.common.serializer.JsonEnumSerializer;

/**
 * @author He mingliang
 * @date 2020/7/30
 */
public class CustomJacksonAnnotationIntrospector extends JacksonAnnotationIntrospector {


    @Override
    public Object findSerializer(Annotated a) {
        JsonEnum ann = _findAnnotation(a, JsonEnum.class);
        if (ann != null) {
            final Class<?> value = ann.value();
            if (value != null) {
                return JsonEnumSerializer.class;
            }
        }

        return super.findSerializer(a);
    }

}
